﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NopSolutions.NopCommerce.Web;
using NopSolutions.NopCommerce.Web.Templates.Payment;
using MediaCoders.NopCommerce.Code.MultiSafePay;

namespace MediaCoders.NopCommerce.Administration.Payment.MultiSafePay
{
    /// <summary>
    /// Configuration control for the MultiSafePay payment provider
    /// </summary>
    public partial class ConfigurePaymentMethod : BaseNopAdministrationUserControl, IConfigurePaymentMethodModule
    {
        #region Event Handlers

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                BindData();
        }

        #endregion

        #region Private Methods 

        private void BindData()
        {
            chkTestAccount.Checked = MultiSafePayPaymentSettings.TestAccount;
            chkAutoStatusProcess.Checked = MultiSafePayPaymentSettings.AutoStatusProcess;
            chkCancelOrderOnPaymentCancel.Checked = MultiSafePayPaymentSettings.CancelOrderOnPaymentCancel;
            txtAccountId.Text = MultiSafePayPaymentSettings.AccountId;
            txtSiteId.Text = MultiSafePayPaymentSettings.SiteId;
            txtSiteCode.Text = MultiSafePayPaymentSettings.SiteCode;
            txtAdditionalFee.Value = MultiSafePayPaymentSettings.AdditionalFee;
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Stores the values to the MultiSafePaySettings
        /// </summary>
        public void Save()
        {
            MultiSafePayPaymentSettings.TestAccount = chkTestAccount.Checked;
            MultiSafePayPaymentSettings.AutoStatusProcess = chkAutoStatusProcess.Checked;
            MultiSafePayPaymentSettings.CancelOrderOnPaymentCancel = chkCancelOrderOnPaymentCancel.Checked;
            MultiSafePayPaymentSettings.AccountId = txtAccountId.Text;
            MultiSafePayPaymentSettings.SiteId = txtSiteId.Text;
            MultiSafePayPaymentSettings.SiteCode = txtSiteCode.Text;
            MultiSafePayPaymentSettings.AdditionalFee = txtAdditionalFee.Value;
        }

        #endregion
    }
}